/*
 *  @ProductName@
 *  Copyright (C) @CopyrightYear@
 *    National Institute of Advanced Industrial Science and Technology (AIST)
 *    Registration Number: @AISTRegistrationNumber@
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package jp.go.aist.six.vuln.core.scap.nvd;

import jp.go.aist.six.util.castor.CastorDataStore;
import jp.go.aist.six.vuln.model.scap.nvd.Nvd;
import jp.go.aist.six.vuln.model.scap.vulnerability.Vulnerability;
import java.util.ArrayList;
import java.util.Collection;



/**
 * An NVD data store implementation.
 *
 * @author  Akihito Nakamura, AIST
 * @version $Id: NvdStore.java 256 2010-06-14 03:58:05Z nakamura5akihito $
 */
public class NvdStore
extends CastorDataStore
{

//    /**
//     * Logger.
//     */
//    private static Log  _LOG = LogFactory.getLog( NvdStore.class );



    /**
     * Constructor.
     */
    public NvdStore()
    {
    }




//    /**
//     *
//     */
//    public Vulnerability loadVulnerability(
//                    final String id
//                    )
//    {
//        return load( Vulnerability.class, id );
//    }
//
//
//
//    /**
//     */
//    public Collection<Vulnerability> loadAllVulnerability()
//    {
//        return loadAll( Vulnerability.class );
//    }
//
//
//
//    /**
//     */
//    public List<Vulnerability> searchVulnerability(
//                    final SearchCriteria criteria
//                    )
//    {
//        return search( Vulnerability.class, criteria );
//    }
//
//
//
//    /**
//     */
//    public int countVulnerability(
//                    final Binding filter
//                    )
//    {
//        return count( Vulnerability.class, filter );
//    }



    /**
     */
    public Object createNvd(
                    final Nvd nvd
                    )
    {
        Collection<Vulnerability>  vuln_list = nvd.getEntry();
        if (vuln_list != null  &&  vuln_list.size() > 0) {
            Collection<Vulnerability>  p_vuln_list = new ArrayList<Vulnerability>();
            for (Vulnerability  vuln : vuln_list) {
                Vulnerability  p_vuln = sync( Vulnerability.class, vuln );
                p_vuln_list.add( p_vuln );
            }
            nvd.setEntry( p_vuln_list );
        }

        return create( Nvd.class, nvd );
    }

}
// NvdStore
